<template>
    <div>
        请输入用户名：<input type="text" v-model="username">
        <button @click="get_request">登录</button>
    </div>
</template>



<script>
export default {
    data(){
        return{
            username:'',
        }
    },
    methods: {
        // 登录
        get_request(){
            this.axios.get('http://localhost:8000/login/',{params:{username:this.username}}).then(res=>{
                console.log(res)
                if(res.data.code==200){
                    alert('登录成功')
                    localStorage.setItem('uid',res.data.uid)
                    localStorage.setItem('username',res.data.username)
                    this.$router.push('/myorder')
                }
            })
        }
    },
}
</script>